﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
///DbHelper 的摘要说明
/// </summary>
public class DbHelper
{
    private static ManageData md = null;
	public DbHelper()
	{
        md = new ManageData(util.DATACONNECTION);
		//
		//TODO: 在此处添加构造函数逻辑
		//
        
	}

    public static bool ExecNonQuery(string sql)
    {
        int ret = 0;
        if (md == null)
        {
            new DbHelper();
        }
        if (md != null)
        {
            ret = md.ExecNonQuery(sql);
        }
        return ret > 0 && ret != 0;
    }

    public static DataTable getTable(string sql)
    {
        DataTable ret = null;
        DataSet set = null;
        if (md == null)
        {
            new DbHelper();
        }
        if (md != null)
        {
            set = md.ExecDS(sql);
        }
        if (set != null &&
            set.Tables != null &&
            set.Tables.Count > 0)
        {
            ret = set.Tables[0];
        }

        return ret;
    }

    public static DataTable selectTable(string table, string selector)
    {
        string sql = "select * from " + table;
        if (selector != null)
        {
            sql += " " + selector;
        }
        return getTable(sql);
    }

    public DataSet ExeSql(string sql)
    {
        return md.ExecDS(sql);
    }
}
